//
//  CapitalSheet.swift
//  Exchange
//
//  Created by 孟祥群 on 2018/7/23.
//  Copyright © 2018年 common. All rights reserved.
//

import UIKit

class CapitalSheet: SelectBaseSheet {
    var model: CapitalModel?
    var config:CapitalConfig?
    init(model: SheetModel, coinfig: SelectConfig, selectStr:String? ,dataSource: SelectmangerDelegate) {
        super.init(model: model, coinfig: coinfig, titleArr: [], selectStr: nil, dataSource: dataSource)
        self.model = model as? CapitalModel
        self.config = coinfig as? CapitalConfig
        self.model?.curretnStr = selectStr
        self.setUpUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func setUpUI() {
        super.setUpUI()
        config?.viewHeight = (config?.capitalHeight)! + (config?.cellHeight)! + CGFloat((config?.spaceNumber)!) + (config?.capitalHeadHeight)! + (isiPhoneX() ? 34 : 0)
        let height = (kSCREEN_HEIGHT - (config?.viewHeight)!)
        selectView.frame = CGRect(x: 0, y:height, width: kSCREEN_WIDTH, height: (config?.viewHeight)!)
        let sheetView = SheetCapitalView(config: config!,model:model!, dataSource: self.dataSource!)
        selectView.addSubview(sheetView)
        sheetView.snp.makeConstraints { (make) in
            make.left.right.equalToSuperview()
            make.top.equalToSuperview().offset(60)
            make.height.equalTo((config?.capitalHeight)!)
        }
        
        let headview = UIView(frame: CGRect(x: 0, y: 0, width: kSCREEN_WIDTH, height: (config?.capitalHeadHeight)! - 5))
        selectView.addSubview(headview)
        headview.themeBackground = ThemeManager.ThemeColorKeys.background
        
        let label = BaseLabel(style: .oneStyle)
        label.text = kText("资金明细类型")
        label.font = UIFont(name: "PingFang-SC-Heavy", size: 18)
        headview.addSubview(label)
        label.snp.makeConstraints { (make) in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview()
        }
        
        let cancelBtn = UIButton()
        cancelBtn.setTitle(kText("取消"), for: UIControlState.normal)
        cancelBtn.themeBackground = ThemeManager.ThemeColorKeys.background
        cancelBtn.setTitleColor(config?.cancelColor, for: UIControlState.normal)
        cancelBtn.addTarget(self, action: #selector(cancelBtnAction), for: UIControlEvents.touchUpInside)
        cancelBtn.titleLabel?.font = UIFont.systemFont(ofSize: CGFloat((config?.titleFont)!))
        selectView.addSubview(cancelBtn)
        cancelBtn.snp.makeConstraints { (make) in
            make.height.equalTo(45 + (isiPhoneX() ? 34 : 0))
            make.bottom.equalToSuperview()
            make.left.right.equalToSuperview()
        }

    }
    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
